<template>
  <!-- 活动列表 -->
  <div style="height:520px">
    <TopFilter
      :list="topFilterInit"
      :cols="3"
      labelWidth="100"
      :collapse="false"
      @filterChange="changeHandle"
      @onCollapse="collapseHandle"
    ></TopFilter>
    <FilterTable
      ref="table"
      :columns="columns"
      :fetchapi="fetchParams"
      :params="flterValue"
      :datakey="'records'"
      :onColumnsChange="columns => this.columns = columns"
      :onRowSelectChange="selectChange"
      columnsRef="projectOperating_projram_commonForm_infoCauseDialog_01"
    ></FilterTable>
    <div class="dialogBottmView">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button @click="saveDialog" type="primary">保 存</el-button>
    </div>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
// import { getShiYeDept } from '@/api/cms-api/projectOperating/program/push';
import { getRegion } from '@/api/cms-common/dealerdata';

export default {
  mixins: [dictionary],
  data() {
    this.saveData = {};
    return {
      visibleDialog: false,
      initModal: {},
      topFilterInit: this.topFilterInitFun(),
      flterValue: {}, //参数
      columns: this.creatHeader(),
      fetchParams: getRegion, //ipa 接口
      selectData: []
    };
  },
  mounted() {
    this.BaseTable = this.$refs.table.$refs.pageTable;
    //请求接口进行赋值，自己写吧
  },
  methods: {
    //搜索数据
    topFilterInitFun() {
      return [
        { type: 'INPUT', label: '事业部代码', fieldName: 'orgCode', placeholder: '请输入', initialValue: '' },
        { type: 'INPUT', label: '事业部名称', fieldName: 'orgName', placeholder: '请输入', initialValue: '' }
      ];
    }, //搜索获取数据
    changeHandle(val) {
      
      this.flterValue = Object.assign({},val);
      // console.log(val);
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '事业部代码', dataIndex: 'orgCode', sorter: true },
        { title: '事业部名称', dataIndex: 'orgName', sorter: true }
      ];
    },
    //复选框选择
    selectChange(data) {
      // debugger
      this.selectData = data;
    },
    //保存
    saveDialog() {
      // console.log("infoCauseDialog1:",this.selectData)
      this.$emit('close', { visible: false, data: this.selectData });
    },
    //取消操作
    closeDialog() {
      this.$emit('close', this.selectData);
    },

    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    }
  }
};
</script>
